// Author: wsfuyibing <682805@qq.com>
// Date: 2025-05-18

package header

import (
	"server/app/http/models"
	"server/app/kind"
)

type (
	// Response
	// 出参.
	Response struct {
		Arcade  *ArcadeResponse
		Swipers []*SwiperResponse
	}

	ArcadeResponse struct {
		Id               kind.ArcadeId
		Verified         kind.ArcadeVerified
		VerifiedFlag     string
		VerifiedText     string
		VerifiedYes      bool
		Balance          kind.Balance
		MemberCount      int
		MemberTotal      int
		MemberEnabled    kind.Enabled
		MemberEnabledYes bool
		ShopCount        int
		ShopTotal        int
		ShopEnabled      kind.Enabled
		ShopEnabledYes   bool
		FollowCount      int
		Latitude         kind.GeoPoint
		Longitude        kind.GeoPoint
		Name             string
		Address          string
	}

	SwiperResponse struct {
		Title string
		Image string
	}
)

func NewResponse() *Response {
	return &Response{
		Arcade:  &ArcadeResponse{},
		Swipers: make([]*SwiperResponse, 0),
	}
}

func (o *Response) AddSwiper(m *models.ArcadeSwiper) *Response {
	o.Swipers = append(o.Swipers, &SwiperResponse{
		Title: m.Title,
		Image: m.Image,
	})
	return o
}

func (o *ArcadeResponse) With(m *models.Arcades) *ArcadeResponse {
	o.Id = m.Id
	o.Verified = m.Verified
	o.VerifiedFlag = m.Verified.Flag()
	o.VerifiedText = m.Verified.Text()
	o.VerifiedYes = m.Verified.IsVerified()
	o.Balance = m.Balance
	o.MemberCount = m.MemberCount
	o.MemberTotal = m.MemberTotal
	o.MemberEnabled = m.MemberEnabled
	o.MemberEnabledYes = m.MemberEnabled.IsYes()
	o.ShopCount = m.ShopCount
	o.ShopTotal = m.ShopTotal
	o.ShopEnabled = m.ShopEnabled
	o.ShopEnabledYes = m.ShopEnabled.IsYes()
	o.FollowCount = m.FollowCount
	o.Latitude = m.Latitude
	o.Longitude = m.Longitude
	o.Name = m.Name
	o.Address = m.Address
	return o
}
